package com.xhsj.user.pms.patent.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import com.xhsj.user.hr.process.dto.pam.TransferPCTOrPRCDataDto;
import com.xhsj.user.hr.system.mapper.TbGlobalUserMapper;
import com.xhsj.user.pms.base.BaseController;
import com.xhsj.user.pms.common.constant.IdentifyConstant;
import com.xhsj.user.pms.common.constant.JumpConstant;
import com.xhsj.user.pms.common.constant.StatusConstant;
import com.xhsj.user.pms.oareply.dto.FindToAuditDto;
import com.xhsj.user.pms.oareply.service.TbPamPatentOaCorrectionService;
import com.xhsj.user.pms.oareply.service.TbPamPatentOaRecheckService;
import com.xhsj.user.pms.oareply.service.TbPamPatentOaService;
import com.xhsj.user.pms.oareply.vo.FindToAuditVo;
import com.xhsj.user.pms.oareply.vo.PatentOaRunTaskVo;
import com.xhsj.user.pms.patent.domain.*;
import com.xhsj.user.pms.patent.dto.FindRunTaskDto;
import com.xhsj.user.pms.patent.dto.PatentByArchivesNumDto;
import com.xhsj.user.pms.patent.dto.PatentByModelTypeDto;
import com.xhsj.user.pms.patent.mapper.*;
import com.xhsj.user.pms.patent.query.SendMessagePatentQuery;
import com.xhsj.user.pms.patent.service.DisclosureService;
import com.xhsj.user.pms.patent.service.TbPamOverseasApplyService;
import com.xhsj.user.pms.patent.vo.FindRunTaskVo;
import com.xhsj.user.pms.workflow.service.WorkflowExecService;
import com.xhsj.user.utils.DateUtils;
import com.xhsj.user.utils.IdGen;
import com.xhsj.user.utils.Message;
import com.xhsj.user.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @Description:交底书功能
 * @Auther: 罗季嘉
 * @Date: 2020/1/16 17:54
 */
@Api(value = "交底书", description = "交底书")
@RestController
@RequestMapping("/disclosure")
@Slf4j
@CrossOrigin(origins = "*", maxAge = 3600)
public class DisclosureController extends BaseController {

    @Autowired
    private DisclosureService disclosureService;
    @Autowired
    private DisclosureMapper disclosureMapper;
    @Autowired
    private TbGlobalUserMapper userMapper;
    @Autowired
    private TbPamPatentOverseasFileMapper tbPamPatentOverseasFileMapper;
    @Autowired
    private PatentMapper patentMapper;
    @Autowired
    private PatentApplyProjectMapper patentApplyProjectMapper;
    @Autowired
    private PatentFileMapper patentFileMapper;
    @Autowired
    private TbPamJudgesReviewRecordMapper judgesReviewRecordMapper;
    @Autowired
    private WorkflowExecService workflowExecService;
    @Autowired
    private JudgesUserMapper  judgesUserMapper;
    @Autowired
    private TbPamInventorProposalIprMapper tbPamInventorProposalIprMapper;

    @Autowired
    private TbPamJudgesIprMapper tbPamJudgesIprMapper;

    @Autowired
    private TbPamOverseasApplyService  tbPamOverseasApplyService;

    @Autowired
    public TbPamPatentOaCorrectionService tbPamPatentOaCorrectionService;

    @Autowired
    public TbPamPatentOaService tbPamPatentOaService;

    @Autowired
    public TbPamPatentOaRecheckService tbPamPatentOaRecheckService;


    @Value("${rolekeyname.generalManager}")
    private String generalManager;

    @Value("${dept.deptName}")
    private String deptName;

    @Value("${ipr.iprName}")
    private String iprName;

    //流程专员
    @Value("${rolekeyname.assistantName}")
    private String assistantName;


    /**
     * 创建交底书
     *
     * @return
     */
    @ApiOperation(value = "创建交底书", notes = "创建交底书")
    @PostMapping("/createDisclosure/v1")
    public Message createDisclosure(@RequestBody Disclosure disclosure) {
        try {

            List<Long> inventorProposalIprs = disclosure.getInventorProposalIprs();
            if (inventorProposalIprs.size() > 1) {
                return Message.error("只能选择一个IPR");
            }
            disclosure.setSignificanceIdentify(1);
            Long userId = disclosure.getCreatedUser();
            String uuid = IdGen.generateUUID();
            disclosure.setDisclosureId(uuid);
            // 获取用户领导id
            Long users = userMapper.getLeaderId(userId);
            if (users == null) {
                return Message.error("上级领导不存在,不能执行流程");
            }
            String label = IdentifyConstant.USER;
            int jumpForm = JumpConstant.DEPT_AUDIT;
            //验证交底书编号是否唯一
            if (disclosureService.getNumCount(disclosure.getNum()) == 0) {
                disclosure.setApplyNum(0);
                disclosureService.createDisclosureAndFile(disclosure, users, label, jumpForm, generalManager, deptName);
            }
            return Message.success();
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error(e.getMessage());
        }
    }

    @ApiOperation(value = "重新提交", notes = "重新提交")
    @PostMapping("/reSubmit")
    public Message reSubmit(@RequestBody Disclosure disclosure) {

        try {
            List<Long> inventorProposalIprs = disclosure.getInventorProposalIprs();
            if (inventorProposalIprs.size() > 1) {
                return Message.error("只能选择一个IPR");
            }
            // 先删除
            disclosureMapper.delDisclosureAndProcess(disclosure.getDisclosureId());

            // 获取用户领导id
            Long users = userMapper.getLeaderId(disclosure.getCreatedUser());
            if (users == null) {
                return Message.error("上级领导不存在,不能执行流程");
            }
            String label = IdentifyConstant.USER;
            int jumpForm = JumpConstant.DEPT_AUDIT;
            //验证交底书编号是否唯一
            if (disclosureService.getNumCount(disclosure.getNum()) == 0) {
                disclosure.setApplyNum(0);
                disclosure.setSignificanceIdentify(1);
                disclosure.setDisclosureId(IdGen.uuid());
                disclosureService.createDisclosureAndFile(disclosure, users, label, jumpForm, generalManager, deptName);
            }

            return Message.success("修改成功");
        } catch (Exception e) {
            log.error("重新提交出错,{}",e);
            return Message.error("修改失败!");
        }
    }


    @ApiOperation(value = "修改交底书", notes = "修改交底书")
    @PostMapping("/updateDisclosure")
    public Message updateDisclosure(@RequestBody Map<String, Object> param) {
        try {
            workflowExecService.updateDisclosure(param);
            return Message.success("修改成功");
        } catch (Exception e) {
            log.error("修改失败,{}",e);
            return Message.error(e.getMessage());
        }
    }

    @ApiOperation(value = "ipr修改案卷号", notes = "ipr修改案卷号")
    @PostMapping("/updateArchivesNum")
    public Message updateArchivesNum(@RequestBody Map<String, Object> param) {
        try {
            workflowExecService.updateArchivesNum(param);
            return Message.success("修改成功");
        } catch (Exception e) {
            log.error("修改失败,{}",e);
            return Message.error(e.getMessage());
        }
    }

    /**
     * 获取我的交底书列表
     *
     * @param
     * @return
     */
    @ApiOperation(value = "获取我的交底书列表", notes = "获取我的交底书列表")
    @PostMapping("/selectMyPatentList")
    public Message selectMyPatentList(@RequestBody Map<String, Object> param) {
        int pageNum = 1;
        int pageSize = 20;
        if (StringUtils.isNotNull(param.get("pageNum"))) {
            pageNum = Integer.parseInt(String.valueOf(param.get("pageNum")));
        }
        if (StringUtils.isNotNull(param.get("pageSize"))) {
            pageSize = Integer.parseInt(String.valueOf(param.get("pageSize")));
        }
        Page<Disclosure> page = new Page(pageNum,pageSize);
        Long userId = Long.valueOf(String.valueOf(param.get("userId")));
        IPage<Disclosure> disclosures = disclosureService.selectMyPatentList(page,userId, param,assistantName);
        return Message.success("成功",disclosures.getRecords(),disclosures.getTotal());
    }

    /**
     * ipr技术方案编写 查询交底书详细信息
     *
     * @author 苏小林
     * @date 2020/2/25 14:03
     */
    @ApiOperation(value = "ipr技术方案编写 查询交底书详细信息", notes = "ipr技术方案编写 查询交底书详细信息")
    @GetMapping("/getDisclosureDetailPlanToWrite")
    public Object getDisclosureDetailPlanToWrite(@RequestParam(value = "disclosureId") String disclosureId) {

        try {
            Map<String, Object> map = disclosureService.getDisclosureDetailPlanToWrite(disclosureId);
            return Message.success("成功", map);
        } catch (Exception e) {
            log.error("ipr技术方案编写 查询交底书详细信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }


    /**
     * 获取分配IPR
     * @author 苏小林
     * @date 2020/7/6 14:35
     * 1 重要 2 一般
     */
    @ApiOperation(value = "获取分配IPR", notes = "获取分配IPR")
    @GetMapping("/getAllotIpr")
    public Message getAllotIpr(@RequestParam("significanceIdentify") int significanceIdentify,
                               @RequestParam("disclosureId") String disclosureId,
                               @RequestParam("protectType") String protectType,
                               @RequestParam("judgesId") String judgesId) {

        if ("3".equals(protectType)) {// 外观设计
            List<Long> list = userMapper.getUserIdByRoleName(assistantName);
            if (list !=null && list.size() >0) {
                return Message.success("成功", list.get(0));
            }
            return Message.success("成功", "");
        } else {
            List<AllotIpr> allotIprs = Lists.newArrayList();
            /*第一步 计算工作量饱和度*/
            Map<String, Object> map = Maps.newHashMap();
            // 查询各个ipr当前工作量
            List<IprWorkLoad> list = disclosureService.getIprWorkload();
            for (IprWorkLoad iprWorkLoad : list) {
                // 包含
                if (map.containsKey(iprWorkLoad.getIprId())) {
                    Integer integerValue = StringUtils.getIntegerValue(map, iprWorkLoad.getIprId());
                    int number = iprWorkLoad.getNumber();
                    int total = integerValue + number;
                    map.put(iprWorkLoad.getIprId(),total);
                } else {
                    map.put(iprWorkLoad.getIprId(),iprWorkLoad.getNumber());
                }
            }
            // 查询部门总工作量
            int count = disclosureMapper.getAllWorkload();
            // 获取ipr人员列表
            List<Map<String,Object>> iprs = disclosureMapper.getIprNumber();
            /*第二步 查询发明人建议*/
            List<Long> inventorAdvice = tbPamInventorProposalIprMapper.getUserIdByDisclosureId(disclosureId);

            List<String> judgesIprs = tbPamJudgesIprMapper.getJudgesIprs(judgesId);

            for (Map<String,Object> iprMap : iprs) {
                AllotIpr allotIpr = new AllotIpr();
                Long userId = StringUtils.getLongValue(iprMap, "userId");
                Long roleId = StringUtils.getLongValue(iprMap, "roleId");
                // 工作年限
                String yearsofWorking = StringUtils.getStringValue(iprMap, "yearsofWorking");
                if (StringUtils.isNotBlank(yearsofWorking)) {
                    yearsofWorking = yearsofWorking.replace("年","").trim();
                }
                // ipr当前处理案件量
                Integer integerValue = StringUtils.getIntegerValue(map, userId+"");
                // 工作量饱和度：当前处理案件量（X）/部门处理案件总量（M）*IPR人数（n）
                String divX = "0";
                if (count != 0) {
                      divX = StringUtils.div(integerValue, count, 2);
                }
                String mul = StringUtils.mul(divX, iprs.size(), 2);
//            System.err.println("当前ipr:"+userId+",工作量饱和度:"+mul);
                log.info("当前IPR:{},工作量饱和度:{}",userId,mul);
                allotIpr.setIprId(userId+"");
                allotIpr.setWorkLoadSaturation(mul);// 工作量饱和度

                /*第三步 技术领域匹配数*/
                if (judgesIprs != null && judgesIprs.size()>0) {
                    if (judgesIprs.contains(userId+"")) {
                        allotIpr.setMatchNumber("1");// 技术领域匹配数
                    }else{
                        allotIpr.setMatchNumber("0.3");// 技术领域匹配数
                    }
                } else {
                    allotIpr.setMatchNumber("0.3");// 技术领域匹配数
                }

                /*第四步 计算业务水平*/
                // 业务系数(A) = (工作年限/10)*20% + (评审通过案件数/评审案件总数)*80%    --暂定 (评审通过案件数/评审案件总数) = 1
                // 计算业务系数A
                String mul1 = StringUtils.mul(StringUtils.div(yearsofWorking, 10, 2), 0.2, 2);
                String A = StringUtils.add(mul1, 0.8);
                if (significanceIdentify == 1) { // 重要专利
                    allotIpr.setBusinessNumber(A);// 业务数
                } else {
                    allotIpr.setBusinessNumber(StringUtils.sub(1,A));// 业务数
                }

                if (inventorAdvice !=null && inventorAdvice.size()>0) {
                    for (Long ia : inventorAdvice) {
                        String s=String.valueOf(ia);
                        if (s.equals(userId+"")) {
                            allotIpr.setInventorNumber("1.2");// 发明人建议系数
                        }else{
                            allotIpr.setInventorNumber("1");// 发明人建议系数
                        }
                    }
                } else {
                    allotIpr.setInventorNumber("1");// 发明人建议系数
                }
                allotIprs.add(allotIpr);

            }
            for (AllotIpr allotIpr : allotIprs) {
                // 案件匹配度=（1-IPR工作饱和度+IPR业务系数+IPR技术领域匹配系数）*发明人建议系数
                String add = StringUtils.add(StringUtils.add(StringUtils.sub(1, allotIpr.getWorkLoadSaturation()), allotIpr.getBusinessNumber()), allotIpr.getMatchNumber());
                String mul = StringUtils.mul(add, allotIpr.getInventorNumber(),2);
                allotIpr.setCaseMatchNumber(mul);
                System.err.println(allotIpr.toString());
                log.info("ipr:{},案件匹配度:{}",allotIpr.getIprId(),mul);
            }


            // 获取出最大的
            AllotIpr allotIpr3 = allotIprs.stream().sorted(Comparator.comparing(AllotIpr::getCaseMatchNumber).reversed()).findFirst().get();
            List<AllotIpr> collect = allotIprs.stream().filter(allotIpr -> allotIpr.getCaseMatchNumber().equals(allotIpr3.getCaseMatchNumber())).collect(Collectors.toList());
            // 如果有多个匹配度相同 选工作量小的
            if (collect.size()>1) {
                AllotIpr allotIpr = collect.stream().sorted(Comparator.comparing(AllotIpr::getWorkLoadSaturation)).findFirst().get();
                log.info("最合适的IPR:{}",allotIpr.getIprId());
                return Message.success("成功", allotIpr.getIprId());
            }
            log.info("最合适的IPR:{}",allotIpr3.getIprId());
            return Message.success("成功", StringUtils.toLong(allotIpr3.getIprId()));
        }
    }

    /**
     * 发明人回复专利撰写人数据查询
     *
     * @author 苏小林
     * @date 2020/2/27 10:50
     * @param: disclosureId
     * @return: com.xhsj.patentmanager.utils.Message
     */
    @ApiOperation(value = "发明人回复专利撰写人数据查询", notes = "发明人回复专利撰写人数据查询")
    @GetMapping("/inventorReplyCreateUser")
    public Message inventorReplyCreateUser(@RequestParam(value = "disclosureId") String disclosureId) {

        try {
            Map<String, Object> map = disclosureService.inventorReplyCreateUser(disclosureId);
            return Message.success("成功", map);
        } catch (Exception e) {
            log.error("发明人回复专利撰写人数据查询异常:{}", e);
            return Message.error(1, "发明人回复专利撰写人数据查询异常");
        }

    }

    /**
     * 获取交底书编号
     *
     * @return
     */
    @GetMapping("/getNewNum/v1")
    @ApiOperation(value = "获取交底书编号", notes = "获取交底书编号")
    public Map<String, String> getNewNum() {
        Map<String, String> map = new HashMap<>();
        String newNum = disclosureService.getNewNum();
        map.put("msg", newNum);
        return map;
    }

    /**
     * 获取交底书以及文件集合
     *
     * @author 苏小林
     * @date 2020/2/25 10:53
     * @param: disclosureId
     */
    @ApiOperation(value = "获取交底书以及文件集合", notes = "获取交底书以及文件集合")
    @GetMapping("/getDisclosureAndFileList/v1")
    public Message getDisclosureAndFileList(@RequestParam("disclosureId") String disclosureId,
                                             @RequestParam("fileType") Integer fileType,
                                             @RequestParam(value = "jumpForm",required = false) Long jumpForm) {

        try {
            if (StringUtils.isBlank(disclosureId)) {
                return Message.error(1, "交底书id不能为空");
            }
            if (StringUtils.isNull(fileType)) {
                return Message.error(1, "交底书文件类型不能为空");
            }
            Disclosure disclosure = disclosureService.getDisclosureByDisclosureId(disclosureId, fileType);// checkType = 0 代表未被选择
            return Message.success("成功", disclosure);
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error(1, "查询失败:" + e.getMessage());
        }
    }

    /**
     * 获取IPR查新数据
     *
     * @author 苏小林
     * @date 2020/2/25 10:53
     * @param: disclosureId
     */
    @ApiOperation(value = "获取IPR查新数据", notes = "获取IPR查新数据")
    @GetMapping("/getIprCxData")
    public Message getIprCxData(@RequestParam("disclosureId") String disclosureId, @RequestParam("fileType") Integer fileType) {

        try {
            if (StringUtils.isBlank(disclosureId)) {
                return Message.error(1, "交底书id不能为空");
            }

            if (StringUtils.isNull(fileType)) {
                return Message.error(1, "交底书文件类型不能为空");
            }
            Disclosure disclosure = disclosureService.getIprCxData(disclosureId, fileType);// checkType = 0 代表未被选择
            return Message.success("成功", disclosure);
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error(1, "查询失败:" + e.getMessage());
        }
    }


    /**
     * 获取交底书重新提交数据-流程退回到创建人时候查询接口
     *
     * @author 苏小林
     * @date 2020/3/2 15:35
     * @param: disclosureId
     * @return: com.xhsj.patentmanager.utils.Message
     */
    @ApiOperation(value = "获取交底书重新提交数据", notes = "获取交底书重新提交数据")
    @GetMapping("/getDisclosureResubmitData")
    public Message getDisclosureResubmitData(@RequestParam("disclosureId") String disclosureId) {
        try {
            Map<String, Object> list = disclosureService.getDisclosureResubmitData(disclosureId);
            return Message.success("获取交底书重新提交数据成功", list);
        } catch (Exception e) {
            log.info("获取交底书重新提交数据错误信息，{}", e.getMessage());
            return Message.error(1, "获取交底书重新提交数据错误");
        }
    }


    /**
     * 创建人回复IPR沟通记录
     *
     * @author 苏小林
     * @date 2020/3/4 11:19
     * @param: disclosureId
     * @return: com.xhsj.patentmanager.utils.Message
     */
    @ApiOperation(value = "创建人回复IPR沟通记录", notes = "创建人回复IPR沟通记录")
    @GetMapping("/getCreatorReplyIprData")
    public Message getCreatorReplyIprData(@RequestParam("disclosureId") String disclosureId) {

        try {
            Map<String, Object> list = disclosureService.getCreatorReplyIprData(disclosureId);
            return Message.success("创建人回复IPR沟通记录", list);
        } catch (Exception e) {
            log.error("创建人回复IPR沟通记录错误:{}", e.getMessage());
            return Message.error(1, "创建人回复IPR沟通记录错误");
        }
    }


    /**
     * 获取完整申请文件审核数据~ipr互审和技术负责人终审
     *
     * @author 苏小林
     * @date 2020/2/25 10:53
     * @param: disclosureId
     */
    @ApiOperation(value = "获取完整申请文件审核数据~ipr互审和技术负责人终审", notes = "获取完整申请文件审核数据~ipr互审和技术负责人终审")
    @GetMapping("/getCompleteApplyFileData")
    public Message getCompleteApplyFileData(@RequestParam("disclosureId") String disclosureId, @RequestParam("fileType") Integer fileType) {

        try {
            if (StringUtils.isBlank(disclosureId)) {
                return Message.error(1, "交底书id不能为空");
            }

            if (StringUtils.isNull(fileType)) {
                return Message.error(1, "交底书文件类型不能为空");
            }
            Disclosure disclosure = disclosureService.getDisclosureByDisclosureId(disclosureId, fileType);// checkType = 2 代表完整申请文件
            return Message.success("成功", disclosure);
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error(1, "查询失败:" + e.getMessage());
        }
    }

    /**
     * 获取交底书审核相关的意见
     *
     * @author 苏小林
     * @date 2020/3/6 10:08
     * @param: disclosureId
     * @return: com.xhsj.patentmanager.utils.Message
     */
    @ApiOperation(value = "获取交底书审核相关的意见", notes = "获取交底书审核相关的意见")
    @GetMapping("/getOpinions")
    public Message getOpinions(@RequestParam("disclosureId") String disclosureId) {
        Map<String, List<OpinionsAndFile>> opinions = disclosureService.getOpinions(disclosureId);
        return Message.success("成功", opinions);

    }


    /**
     * 获取提交记录前查询专利数据
     *
     * @author 苏小林
     * @date 2020/2/27 10:16
     * @param: disclosureId
     * @return: com.xhsj.patentmanager.utils.Message
     */
    @ApiOperation(value = "获取提交记录前查询专利数据", notes = "获取提交记录前查询专利数据")
    @GetMapping("/getBeforeSubmitRecordData")
    public Message getBeforeSubmitRecordData(@RequestParam("disclosureId") String disclosureId) {
        try {
            Map<String, Object> map = disclosureService.getBeforeSubmitRecordData(disclosureId);
            return Message.success("成功", map);
        } catch (Exception e) {
            log.error("获取提交记录前查询专利数据异常:{}", e);
            return Message.error(1, "失败");
        }
    }


    /**
     * 获取部门集合
     *
     * @return
     */
    @GetMapping("/getDeptAll/v1")
    @ApiOperation(value = "当获取部门集合", notes = "获取部门集合")
    public Message getDeptAll() {
        try {
            return Message.success("成功", disclosureService.getDeptAll());
        } catch (Exception e) {
            return Message.error(1, "失败");
        }
    }

    /**
     * 技术交底书列表
     *
     * @return
     */
    @PostMapping("/getTechnologyDisclosure/v1")
    @ApiImplicitParam(name = "param", value = "{\n" +
            "\"disclosureId\":\"交底书ID/专利ID\",\n" +
            "}", required = true, dataType = "Map")
    @ApiOperation(value = "技术交底书列表", notes = "技术交底书列表")
    public Message getTechnologyDisclosure(@RequestBody Map<String, Object> param) {
        try {
            log.info("技术交底书查询参数{}，", param);
            if (StringUtils.isNull(param.get("disclosureId"))) {
                return Message.error(1, "disclosureId参数不能为空");
            }
            List<Map<String, Object>> disclosureIdList = disclosureService.getTechnologyDisclosure(String.valueOf(param.get("disclosureId")));
            return Message.success("成功",disclosureIdList);
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error(1, "失败");
        }
    }

    /**
     * 通过用户id查询部门相关信息
     *
     * @param userId
     * @autoor suxiaolin
     */
    @GetMapping("/getDeptByUserId")
    public Map<String, Object> getDeptByUserId(Long userId) {
        // 通过用户id获取部门信息
        Map<String, Object> map = disclosureMapper.getDeptByUserId(userId);
        return map;
    }

    /**
     * 获取ipr列表
     *
     * @author 苏小林
     * @date 2020/2/25 11:35
     */
    @GetMapping("/getIprList")
    @ApiOperation(value = "获取ipr列表", notes = "获取ipr列表")
    public Message getIPR() {
        try {
            List<Map> maps = userMapper.getPatentDepartUserMap(iprName);
            return Message.success("获取ipr值成功", maps);
        } catch (Exception e) {
            log.info("获取ipr值错误，{}", e.getMessage());
            return Message.error(1, "失败");
        }
    }

    /**
     * 获取已经完成的专利
     *
     * @author 苏小林
     * @date 2020/2/25 10:08
     */
    @GetMapping("/getCompleteDisclosure")
    @ApiOperation(value = "获取已经完成的专利", notes = "获取已经完成的专利")
    public Message getCompleteDisclosure() {
        try {
            String statusId = StatusConstant.S;//已获得通知
//            String statusId = StatusConstant.A;//测试用
            List<Disclosure> disclosure = disclosureService.getDisclosureByStatusId(statusId);
            return Message.success("获取成功", disclosure);
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error(1, "失败");
        }
    }

    /**
     * 选择意见列表
     *
     * @author 苏小林
     * @date 2020/2/26 13:50
     * @return: com.xhsj.patentmanager.utils.Message
     */
    @GetMapping("/selectOpinion")
    @ApiOperation(value = "选择意见列表", notes = "选择意见列表")
    public Message selectOpinion(@RequestParam("disclosureId") String disclosureId) {
        try {

            List<Map<String, Object>> list = disclosureService.selectOpinion(disclosureId);
            return Message.success("获取成功", list);
        } catch (Exception e) {
            log.error("选择意见列表数据获取失败:{}", e);
            return Message.error(1, "失败");
        }
    }

    /**
     * 获取评审会初审数据
     * @author 苏小林
     * @date 2021/1/11 15:39
     * @param: disclosureId
     * @param: fileType
     * @return: com.xhsj.user.utils.Message
     */
    @GetMapping("/firstReviewTrial")
    @ApiOperation(value = "获取评审会初审数据", notes = "获取评审会初审数据")
    public Message firstReviewTrial(@RequestParam("disclosureId") String disclosureId,
                                    @RequestParam("nodeId") String nodeId) {

        try {
            Disclosure disclosure = null;
            // 评审会初审 || 初审评审确认
            if ("97BF5B1F73414EA9BBDB55C62D46B981".equals(nodeId) || "8E7520D906358079B25479F1FB52E258".equals(nodeId) || "270BFB5523784223B122A3ABC5D40793".equals(nodeId)) {
                // 找出最新的申请文件 检索报告
                disclosure= disclosureService.getFirstTrialData(disclosureId,4);
            }
            // 评审会终审 || 评审会终审确认 || 终审总经理确认
            if ("7524DFC3666B40C5A6E6EEFD063F06EA".equals(nodeId) || "04198012fc1c49b68959c05bd492d80f".equals(nodeId) || "77409ADFDC384F46AA3F6B415893E432".equals(nodeId)) {
                // 找出最新的申请文件 权利要求文件
                disclosure= disclosureService.getFirstTrialData(disclosureId,1);
            }



            return Message.success("成功", disclosure);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("技术负责人初审数据查询出错:{}", e);
            return Message.error(1, "失败");
        }

    }


    /**
     * 获取编写申请文件数据 -技术负责人初审通过后
     *
     * @author 苏小林
     * @date 2020/2/26 17:10
     * @param: disclosureId
     * @return: com.xhsj.patentmanager.utils.Message
     */
    @GetMapping("/getEditApplyFileData")
    @ApiOperation(value = "获取编写申请文件数据", notes = "获取编写申请文件数据")
    public Message getEditApplyFileData(@RequestParam(value = "disclosureId") String disclosureId) {
        try {
            // 获取完整申请文件编写数据 就是在ipr技术方案编写 查询交底书详细信息接口的基础上添加技术负责人初审意见
            Map<String, Object> map = disclosureService.getCompleteApplyFileData(disclosureId);
            return Message.success("成功", map);
        } catch (Exception e) {
            log.error("ipr技术方案编写 查询交底书详细信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    //各个级别页面查看
    @ApiOperation(value = "各个级别页面查看", notes = "各个级别页面查看")
    @ApiImplicitParam(name = "param", value = "{\n" +
            "\"pageNum\":当前页,\n" +
            "\"pageSize\":有几条数据,\n" +
            "\"disclosureId\":\"交底书ID/专利ID\"\n" +
            "}", required = true, dataType = "Map")
    @PostMapping("/getWorkFlowRecord/v1")
    @ResponseBody
    public Message getWorkFlowRecord(@RequestBody Map<String, Object> param) {
        try {
            log.info("各个级别页面查看参数{}，", param);
            if (StringUtils.isNull(param.get("disclosureId"))) {
                return Message.error(1, "参数不能为空");
            }
            if (StringUtils.isNull(param.get("createdUser"))) {
                return Message.error(1, "创建者参数不能为空");
            }
            if (StringUtils.isNull(param.get("userId"))) {
                return Message.error(1, "当前用户参数不能为空");
            }
            String disclosureId = String.valueOf(param.get("disclosureId"));
            Long createdUser = Long.valueOf(String.valueOf(param.get("createdUser")));
            Long userId = Long.valueOf(String.valueOf(param.get("userId")));
            Map<String, Object> workFlowRecord = disclosureService.getWorkFlowRecord(disclosureId, createdUser, userId, generalManager);
            return Message.success("各个级别页面成功", workFlowRecord);
        } catch (Exception e) {
            log.error("各个级别页面异常信息:{}", e);
            e.printStackTrace();
            return Message.error(1, "各个级别页面失败");
        }
    }

    //多人审核申请文件列表
    @ApiOperation(value = "多人审核申请文件列表", notes = "多人审核申请文件列表")
    @ApiImplicitParam(name = "param", value = "{\n" +
            "\"pageNum\":当前页,\n" +
            "\"pageSize\":有几条数据,\n" +
            "\"disclosureId\":\"交底书ID/专利ID\"\n" +
            "}", required = true, dataType = "Map")
    @PostMapping("/getManyPeopleFile/v1")
    @ResponseBody
    public Message getManyPeopleFile(@RequestBody Map<String, Object> param) {
        try {
            if (StringUtils.isNull(param.get("disclosureId"))) {
                return Message.error(1, "交底书参数不能为空");
            }
            String disclosureId = String.valueOf(param.get("disclosureId"));
            return Message.success("多人审核申请文件列表成功", disclosureService.getManyPeopleFile(disclosureId));
        } catch (Exception e) {
            log.error("多人审核申请文件列表异常信息:{}", e);
            e.printStackTrace();
            return Message.error(1, "多人审核申请文件列表失败");
        }
    }

    //多人审核查看页面
    @ApiOperation(value = "多人审核查看页面", notes = "多人审核查看页面")
    @PostMapping("/getManyPeopleExamineData/v1")
    @ResponseBody
    public Message getManyPeopleExamineData(@RequestBody Map<String, Object> param) {
        try {
            log.info("多人审核查看页面{}，", param);
            if (StringUtils.isNull(param.get("disclosureId"))) {
                return Message.error(1, "交底书参数不能为空");
            }
            if (StringUtils.isNull(param.get("userId"))) {
                return Message.error(1, "当前用户不能为空");
            }
            if (StringUtils.isNull(param.get("type"))) {
                return Message.error(1, "类型不能为空");
            }
            if (StringUtils.isNull(param.get("patentFileId"))) {
                return Message.error(1, "文件id不能为空");
            }
            String disclosureId = String.valueOf(param.get("disclosureId"));
            String userId = String.valueOf(param.get("userId"));
            String patentFileId = String.valueOf(param.get("patentFileId"));
            String type = String.valueOf(param.get("type"));
            return Message.success("多人审核查看页面成功", disclosureService.
                    getManyPeopleExamineData(disclosureId, userId, patentFileId, type));
        } catch (Exception e) {
            log.error("多人审核申请文件列表异常信息:{}", e);
            e.printStackTrace();
            return Message.error(1, "多人审核申请文件列表失败");
        }
    }

    @ApiOperation(value = "根据报表得到对应人的全部数据二级柱状图", notes = "根据报表得到对应人的全部数据二级柱状图")
    @PostMapping("/getDatasByUser")
    public Message getDatasByUser(@RequestBody Map<String, Object> param) {
        try {
            log.info("二级柱状图根据报表得到对应人的全部数据,{}", param);
            if (StringUtils.isNull(param.get("userId"))) {
                return Message.error(1, "用户不能为空");
            }
            if (StringUtils.isNull(param.get("type"))) {
                return Message.error(1, "区分是年月季不能为空");
            }
            if (StringUtils.isNull(param.get("typeKinds"))) {
                return Message.error(1, "区分类型（交底书数据。。。）参数不能为空");
            }
            String userId = String.valueOf(param.get("userId"));
            String typeKinds = String.valueOf(param.get("typeKinds"));
            if ("8".equals(typeKinds)) {
                typeKinds = "7";
            }
            int type = Integer.valueOf(String.valueOf(param.get("type")));
            List<Map<String, Object>> datasByUser = disclosureService.getDatasByUser(userId, typeKinds, type);
            List<Map<String, Object>> listNum = new ArrayList<>();
            Map<String, Object> map = new HashMap<>();
            for (Map<String, Object> data : datasByUser
            ) {
                String name = String.valueOf(data.get("name"));
                String significanceIdentify = String.valueOf(data.get("significanceIdentify"));
                BigDecimal value = new BigDecimal(String.valueOf(data.get("value")));
                if (map.containsKey(name) && "1".equals(significanceIdentify)) {
                    Map<String, Object> oValue = (Map<String, Object>) map.get(name);
                    oValue.put("value1", value);
                    map.put(name, oValue);
                } else if (map.containsKey(name) && ("2".equals(significanceIdentify) || "0".equals(significanceIdentify))) {
                    Map<String, Object> oValue = (Map<String, Object>) map.get(name);
                    System.out.println(oValue);
                    oValue.put("value", new BigDecimal(String.valueOf(oValue.get("value"))).add(value));
                    map.put(name, oValue);
                } else if ("1".equals(significanceIdentify)) {
                    data.put("value1", value);
                    data.put("significanceIdentify1", Integer.valueOf(significanceIdentify));
                    data.put("value", 0);
                    data.put("significanceIdentify", 2);
                    map.put(name, data);
                } else if ("2".equals(significanceIdentify) || "0".equals(significanceIdentify)) {
                    data.put("value1", 0);
                    data.put("significanceIdentify1", 1);
                    data.put("significanceIdentify", 2);
                    map.put(name, data);
                }
            }
            for (Map.Entry<String, Object> m : map.entrySet()) {
                Map<String, Object> value = (Map<String, Object>) m.getValue();
                listNum.add(value);
            }

            return Message.success("二级柱状图根据报表得到对应人的全部数据成功", listNum);
        } catch (Exception e) {
            log.error("二级柱状图根据报表得到对应人的全部数据异常信息:{}", e);
            e.printStackTrace();
            return Message.error(1, "二级柱状图根据报表得到对应人的全部数据失败");
        }

    }

    @ApiOperation(value = "根据报表得到对应人的具体数据", notes = "根据报表得到对应人的具体数据")
    @PostMapping("/getDatasByUserId")
    public Message getDatasByUserId(@RequestBody Map<String, Object> param) {
        try {
            log.info("根据报表得到对应人的具体数据参数,{}", param);
            if (StringUtils.isNull(param.get("userId"))) {
                return Message.error(1, "用户不能为空");
            }
            if (StringUtils.isNull(param.get("type"))) {
                return Message.error(1, "区分是年月季不能为空");
            }
            if (StringUtils.isNull(param.get("typeKinds"))) {
                return Message.error(1, "区分类型（交底书数据。。。）参数不能为空");
            }
//            if(StringUtils.isNull(param.get("typeParam")))
//                return Message.error(1,"区分哪年哪月哪季不能为空");
            if (StringUtils.isNull(param.get("significanceIdentify"))) {
                return Message.error(1, "区分重要的和不重要的"); //1重要 2普通
            }
            String userId = String.valueOf(param.get("userId"));
//            String  typeParam= String.valueOf(param.get("typeParam"));
            String typeKinds = String.valueOf(param.get("typeKinds"));
            int type = Integer.valueOf(String.valueOf(param.get("type")));
            int significanceIdentify = Integer.valueOf(String.valueOf(param.get("significanceIdentify")));
            List<Map<String, Object>> datasByUser = null;
            return Message.success("根据报表得到对应人的具体数据成功", datasByUser);
        } catch (Exception e) {
            log.error("根据报表得到对应人的具体数据异常信息:{}", e);
            e.printStackTrace();
            return Message.error(1, "根据报表得到对应人的具体数据失败");
        }

    }


    @GetMapping("/getUserNameByNum")
    @ApiOperation(value = "根据工号获取用户名", notes = "根据工号获取用户名")
    public Message getUserNameByNum(@RequestParam(value = "jobNumber", required = false) String jobNumber) {
        try {
            String jobNumberList = userMapper.getUserNameByNum(jobNumber);
            if (StringUtils.isBlank(jobNumberList)) {
                jobNumberList = "";
            }
            return Message.success("成功", jobNumberList);
        } catch (Exception e) {
            log.error("根据工号获取用户名信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    @PostMapping("/getJudgesList")
    @ApiOperation(value = "获取评审会意见列表", notes = "获取评审会意见列表")
    public Message getJudgesList(@RequestBody Map<String, Object> param ) {
        try {
            log.info("获取评审会意见列表参数，{}",param);
            int pageNum = 1;
            int pageSize = 20;
            if (StringUtils.isNotNull(param.get("pageNum"))) {
                pageNum = Integer.parseInt(String.valueOf(param.get("pageNum")));
            }
            if (StringUtils.isNotNull(param.get("pageSize"))) {
                pageSize = Integer.parseInt(String.valueOf(param.get("pageSize")));
            }
            if (StringUtils.isNull(param.get("disclosureId"))) {
                return Message.error(1, "交底书id参数不能为空");
            }
//            PageHelper.startPage(pageNum,pageSize);
            String disclosureId=String.valueOf(param.get("disclosureId"));
            //获取评审会反馈意见列表
            List<Map<String,Object>> judgesList=judgesReviewRecordMapper.getJudgesList(disclosureId);
            return Message.success("成功", judgesList);
        } catch (Exception e) {
            log.error("获取评审会意见列表信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    @PostMapping("/getJudgesListByUserId")
    @ApiOperation(value = "获取评审会意见列表通过用户", notes = "获取评审会意见列表通过用户")
    public Message getJudgesListByUserId(@RequestBody Map<String, Object> param ) {
        try {
            log.info("获取评审会意见列表通过用户参数，{}",param);
            if (StringUtils.isNull(param.get("userId"))) {
                return Message.error(1, "userId用户id参数不能为空");
            }
            String nodeId = StringUtils.getStringValue(param, "nodeId");
            if ("7524DFC3666B40C5A6E6EEFD063F06EA".equals(nodeId)) {// 终审
                param.put("fileType",1);
            }else if ("736ca4d2a36e475daefd92e9828a1489".equals(nodeId)) {// 说明书审核
                param.put("fileType",2);
            }else{
                param.put("fileType",0);
            }
            String disclosureId=String.valueOf(param.get("disclosureId"));
            String userId=String.valueOf(param.get("userId"));
            Integer fileType = StringUtils.toInteger(param.get("fileType"));
            //获取评审会反馈意见列表通过用户
            List<Map<String,Object>> judgesList=judgesReviewRecordMapper.getJudgesListByUserId(disclosureId,userId,fileType);
            return Message.success("成功",judgesList);
        } catch (Exception e) {
            log.error("获取评审会意见列表信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    //回复反馈意见
    @PostMapping("/saveReplayJudgesOpinion")
    @ApiOperation(value = "保存回复评审会反馈意见", notes = "保存回复评审会反馈意见")
    public Message saveReplayJudgesOpinion(@RequestBody TbPamJudgesReviewRecord tbPamJudgesReviewRecord ) {
        try {
            //保存回复评审会意见
            return  disclosureService.replayJudgesOpinion(tbPamJudgesReviewRecord);
        } catch (Exception e) {
            log.error("保存回复评审会反馈意见信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    //新增反馈意见
    @PostMapping("/saveJudgesReviewRecord")
    @ApiOperation(value = "保存评审会反馈意见", notes = "保存评审会反馈意见")
    public Message saveJudgesReviewRecord(@RequestBody Map<String,Object> param) {
        try {
            //保存回复评审会意见
            return  workflowExecService.saveJudgesReviewRecord(param);
        } catch (Exception e) {
            log.error("保存评审会反馈意见信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }


    @GetMapping("/getApplyProject")
    @ApiOperation(value = "根据交底书id获取申请项目信息", notes = "根据交底书id获取申请项目信息")
    public Message getApplyProject(@RequestParam("disclosureId") String disclosureId) {
        try {
            PatentApplyProject patentApplyProject = patentApplyProjectMapper.getApplyProject(disclosureId);
            // 获取答复文件列表
            List<PatentFile> fileListByDataId = tbPamPatentOverseasFileMapper.getFileListByDataId(disclosureId);
            if (fileListByDataId != null && patentApplyProject != null) {
                patentApplyProject.getPatentApplyFileList().addAll(fileListByDataId);
            }
            return Message.success("成功", patentApplyProject);
        } catch (Exception e) {
            log.error("根据工号获取用户名信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }


    @GetMapping("/getPatentInfo")
    @ApiOperation(value = "根据交底书id获取申请项目信息", notes = "根据交底书id获取申请项目信息")
    public Message getPatentInfo(@RequestParam("patentId") String patentId) {
        try {
            Map<String,Object> patentApplyProject = patentMapper.getPatentInfo(patentId);
            List<PatentFile> li = patentFileMapper.getByPatentId(patentId);
            Map<Integer, List<PatentFile>> map = Maps.newHashMap();
            for (PatentFile patentFile : li) {
                Integer fileType = patentFile.getFileType();
                if (map.containsKey(fileType)) {
                    List<PatentFile> patentFiles = map.get(fileType);
                    patentFiles.add(patentFile);
                }else{
                    List<PatentFile> list = Lists.newArrayList();
                    list.add(patentFile);

                    map.put(fileType,list);
                }
            }
            List<PatentFile> patentFiles = map.get(6);
            if (patentFiles == null) {
                patentFiles=new ArrayList<>();
            }
            List<PatentFile> patentFiles1 = map.get(7);
            if (patentFiles1==null) {
                patentFiles1=new ArrayList<>();
            }
            patentApplyProject.put("fileList1",patentFiles);
            patentApplyProject.put("fileList2",patentFiles1);
            return Message.success("成功", patentApplyProject);
        } catch (Exception e) {
            log.error("根据工号获取用户名信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    @GetMapping("/getJudgesUserId")
    @ApiOperation(value = "获取评审会成员", notes = "获取评审会成员")
    public Message getJudgesUserId(@RequestParam("disclosureId") String disclosureId) {
        try {
            List<Long> judgesUserId = judgesUserMapper.getJudgesUserId(disclosureId);
            return Message.success("成功", judgesUserId);
        } catch (Exception e) {
            log.error("根据工号获取用户名信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    @GetMapping("/getCheckIprUserId")
    @ApiOperation(value = "获取选定ipr", notes = "获取选定ipr")
    public Message getCheckIprUserId(@RequestParam("disclosureId") String disclosureId) {
        try {
           String checkIprUserId = patentFileMapper.getCheckIprUserId(disclosureId);
            return Message.success("成功", checkIprUserId);
        } catch (Exception e) {
            log.error("根据工号获取用户名信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    @ApiOperation(value="评审会相关的数据",notes ="评审会相关的数据" )
    @GetMapping("/reviewMeetingRelevantData/v1")
    @ResponseBody
    public Message reviewMeetingRelevantData(@RequestParam("disclosureId") String disclosureId){
        try {
            Map<String,Object> map=new HashMap<>();
            map.put("checkIprUserId",tbPamInventorProposalIprMapper.getAdviceIpr(disclosureId));
            map.put("judgesUserId", judgesUserMapper.getJudgesUserId(disclosureId));
            map.put("currentWorkFlow", workflowExecService.getWorkFlowExec(disclosureId));
            return Message.success("成功",map);
        }catch (Exception e){
            log.error("信息:{}",e);
            e.printStackTrace();
            return Message.error(1,"失败");
        }
    }

    @GetMapping("/patentAgencyNum/v1")
    @ApiOperation(value = "专利代办数", notes = "专利代办数")
    public Message patentAgencyNum(@RequestParam("userId") int userId) {
        try {
            // 国内代办数
            Integer integer = workflowExecService.patentAgencyNum(userId);
            // 海外代办数
            FindRunTaskDto findRunTaskDto = new FindRunTaskDto();
            findRunTaskDto.setCreateBy(new Long(userId));
            IPage<FindRunTaskVo> runTask = tbPamOverseasApplyService.findRunTask(findRunTaskDto);
            long total = runTask.getTotal();
            // oa模块代办数
            // 补正
            FindToAuditDto findToAuditDto = new FindToAuditDto();
            findToAuditDto.setPage(1);
            findToAuditDto.setPageSize(10);
            findToAuditDto.setUserId(new Long(userId));
            IPage<FindToAuditVo> toAudit = tbPamPatentOaCorrectionService.findToAudit(findToAuditDto);
            long total1 = toAudit.getTotal();
            // oa
            com.xhsj.user.pms.oareply.dto.FindRunTaskDto findRunTaskDto1 = new com.xhsj.user.pms.oareply.dto.FindRunTaskDto();
            findRunTaskDto1.setCreateBy(new Long(userId));
            IPage<PatentOaRunTaskVo> runTask1 = tbPamPatentOaService.findRunTask(findRunTaskDto1);
            long total3 = runTask1.getTotal();
            // 驳回
            IPage<FindToAuditVo> approved = tbPamPatentOaRecheckService.findToAudit(findToAuditDto);
            long total2 = approved.getTotal();

            return Message.success("成功",  total1+total2+total3+total+integer);
        } catch (Exception e) {
            log.error("信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

       /**
           * @Description:  冻结专利和解冻专利
           * @Param:  frozenStatus 冻结状态 disclosureId 交底书id
           * @Author: liuqinghua
           * @Date: 2020/8/21
           */
    @GetMapping("/disclosureFrozenStatus/v1")
    @ApiOperation(value = "冻结专利和解冻专利", notes = "冻结专利和解冻专利")
    public Message disclosureFrozenStatus(@RequestParam("frozenStatus") int frozenStatus,
                                          @RequestParam("disclosureId") String disclosureId,
                                          @RequestParam(value = "frozenRemarks") String frozenRemarks) {
        try {
            disclosureService.disclosureFrozenStatus(frozenStatus,disclosureId,frozenRemarks);
            return Message.success("成功");
        } catch (Exception e) {
            log.error("信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

       /**
           * @Description:
           * @Param:OA模块-立案-通过案卷号搜索
           * @Author: liuqinghua
           * @Date: 2021/7/29
           */
       @PostMapping("/getPatentByArchivesNum/v1")
       @ApiOperation(value = "OA答复模块-立案-通过案卷号搜索", notes = "OA答复模块-立案-通过案卷号搜索")
       public Message getPatentByArchivesNum(@RequestBody PatentByArchivesNumDto param) {
           try {
               IPage<Map<String, Object>> patentByArchivesNum = disclosureService.getPatentByArchivesNum(param);
               return Message.success("成功",patentByArchivesNum.getRecords(),patentByArchivesNum.getTotal(),patentByArchivesNum.getPages());
           } catch (Exception e) {
               log.error("信息出错:{}", e);
               return Message.error(1, "失败");
           }
       }
   /**
       * @Description:  OA答复模块-通过模块类型搜索
       * @Author: liuqinghua
       * @Date: 2021/8/4
       */
    @PostMapping("/getPatentByModelType/v1")
    @ApiOperation(value = "OA答复模块-通过模块类型搜索", notes = "OA模块-通过模块类型搜索")
    public Message getPatentByModelType(@RequestBody PatentByModelTypeDto param) {
        try {
            List<Map<String,String>> list = disclosureService.getPatentByModelType(param);
            return Message.success("成功",list);
        } catch (Exception e) {
            log.error("信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

       /**
           * @Description: 专利统计
           * @Param:  date 日期
           * @Author: liuqinghua
           * @Date: 2021/9/6 
           */
    @GetMapping("/getPatentStatistics/v1")
    @ApiOperation(value = "专利统计", notes = "专利统计")
    public Message getPatentStatistics(@RequestParam (value = "date") String date) {
        try {
            // 判断日期格式是否正确
            if(!Pattern.matches( DateUtils.MONTH_REGEX, date))
                return Message.error("日期格式不对，请按照yyyy-MM");
            List<Map<String,Object>> list = disclosureService.getPatentStatistics(date);
            return Message.success("成功",list);
        } catch (Exception e) {
            log.error("信息出错:{}", e);
            return Message.error(1, "失败");
        }
    }

    public static void main(String[] args) {
        SendMessagePatentQuery query = new SendMessagePatentQuery();
        List<SendMessagePatentQuery> recipientList = new ArrayList<>();
        query.setFullName("ww");
        query.setRecipient("290");
        recipientList.add(query);
        List<String> fullNames = recipientList.stream().filter(q -> q.getRecipient().equals("290")).map(l -> l.getFullName()).collect(Collectors.toList());

        UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32).toUpperCase();
        System.out.println(UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32).toUpperCase());

//
//        String pwdStr = Md5Utils.md5Util("13911795127" + "ceshi" + "xhsj");
//        System.out.println(pwdStr);

        List<AllotIpr> objects = Lists.newArrayList();
        AllotIpr allotIpr = new AllotIpr();
        allotIpr.setCaseMatchNumber("1.0");
        objects.add(allotIpr);
        AllotIpr allotIpr1 = new AllotIpr();
        allotIpr1.setCaseMatchNumber("1.1");
        objects.add(allotIpr1);
        AllotIpr allotIpr2 = new AllotIpr();
        allotIpr2.setCaseMatchNumber("1.1");
        objects.add(allotIpr2);

        AllotIpr allotIpr3 = objects.stream().sorted(Comparator.comparing(AllotIpr::getCaseMatchNumber).reversed()).findFirst().get();
        System.err.println(allotIpr3);

        HashSet<AllotIpr> allotIprs = new HashSet<>(objects);
        System.err.println(allotIprs.toString());


        List kist = Arrays.asList(2,11);
        List kist1 = Arrays.asList(1,12);
        System.out.println(kist.contains(kist1.get(1))+"===");
    }

   /**
       * @Description: PCTOrPRCD数据迁徙
       * @Param:
       * @return:
       * @Author: liuqinghua
       * @Date: 2021/4/7
       */
   @PostMapping("/transferPCTOrPRCData/v1")
   @ApiOperation(value = "PCTOrPRCD数据迁徙", notes = "PCTOrPRCD数据迁徙")
    public Message transferPCTOrPRCData(@RequestBody List<TransferPCTOrPRCDataDto> data){
       try {
           // pct or prc数据
           disclosureService.getTransferPCTOrPRCData(data);
           return Message.success("成功");
       } catch (Exception e) {
           log.error("信息出错:{}", e);
           e.printStackTrace();
           return Message.error(1,e.getMessage());
       }

    }

//    @PostMapping("/test/v1")
//    @ApiOperation(value = "test", notes = "test")
//    public Message test(@RequestBody List<TransferPCTOrPRCDataDto> data){
//        try {
//            // pct or prc数据
//            disclosureService.test(data);
//            return Message.success("成功");
//        } catch (Exception e) {
//            log.error("信息出错:{}", e);
//            e.printStackTrace();
//            return Message.error(1,e.getMessage());
//        }
//
//    }
//
//
//
//    @GetMapping("/carousel")
//    @ApiOperation(value = "轮播图数据", notes = "轮播图数据")
//    public Message carousel() {
//        try {
//            List<Map<String,Object>>  carouselList = new ArrayList<>();
//            Map<String,Object> map1 = new HashMap<>();
//            map1.put("id",1);
//            map1.put("url","http://localhost:9976/file/download/hr/erp-user/2021-05-25/9e2c84ecc7e74518bea5a7fd096d8ca2.jpeg");
//            map1.put("name",1);
//            Map<String,Object> map2 = new HashMap<>();
//            map2.put("id",2);
//            map2.put("url","http://localhost:9976/file/download/hr/erp-user/2021-05-25/b0fdbad3b3d14366a7212742b88da9f7.jpeg");
//            map2.put("name",2);
//            Map<String,Object> map3 = new HashMap<>();
//            map3.put("id",3);
//            map3.put("url","http://localhost:9976/file/download/hr/erp-user/2021-05-25/21552493a78a46c58bb3717ca2b4a3a6.jpeg");
//            map3.put("name",3);
//            carouselList.add(map1);
//            carouselList.add(map2);
//            carouselList.add(map3);
//            return Message.success("成功", carouselList);
//        } catch (Exception e) {
//            log.error("信息出错:{}", e);
//            return Message.error(1, "失败");
//        }
//    }
//
//    @GetMapping("/testPost/v1")
//    @ApiOperation(value = "专利代办数", notes = "专利代办数")
//    public Message testPost() {
//        try {
//            List<Map<String,Object>>  carouselList = new ArrayList<>();
//            Map<String,Object> map1 = new HashMap<>();
//            map1.put("id",1);
//            map1.put("url","http://localhost:9976/file/download/hr/erp-user/2021-05-25/9e2c84ecc7e74518bea5a7fd096d8ca2.jpeg");
//            map1.put("name",1);
//            Map<String,Object> map2 = new HashMap<>();
//            map2.put("id",2);
//            map2.put("url","http://localhost:9976/file/download/hr/erp-user/2021-05-25/b0fdbad3b3d14366a7212742b88da9f7.jpeg");
//            map2.put("name",2);
//            Map<String,Object> map3 = new HashMap<>();
//            map3.put("id",3);
//            map3.put("url","http://localhost:9976/file/download/hr/erp-user/2021-05-25/21552493a78a46c58bb3717ca2b4a3a6.jpeg");
//            map3.put("name",3);
//            carouselList.add(map1);
//            carouselList.add(map2);
//            carouselList.add(map3);
//            return Message.success("成功", carouselList);
//        } catch (Exception e) {
//            log.error("信息出错:{}", e);
//            return Message.error(1, "失败");
//        }
//    }


}
